﻿#pragma once



// CRowView 视图

class CRowView : public CScrollView
{
	DECLARE_DYNAMIC(CRowView)
protected:
	CRowView();           // 动态创建所使用的受保护的构造函数
	virtual ~CRowView();

public:
#ifdef _DEBUG
	virtual void AssertValid() const;
#ifndef _WIN32_WCE
	virtual void Dump(CDumpContext& dc) const;
#endif
#endif

protected:
	virtual void OnDraw(CDC* pDC);      // 重写以绘制该视图
	virtual void OnInitialUpdate();     // 构造后的第一次

	DECLARE_MESSAGE_MAP()

	// Attribute
protected:
	int m_nRowWidth;
	int m_nRowHeight;
	int m_nCharWidth;
	int m_nPreSelectedRow;
	int m_nPrevRowCount;
	int m_nRowPerPrintPage;

	// Operation - attibute
protected:
	virtual void UpdateRow(int nValidRow);
	virtual void CalculateMetrics(CDC* pDC);
	virtual void UpdateScrollSizes();
	virtual CRect RowToWndRect(CDC* pDC,int nRow);
	virtual int RowToYPos(int nRow);
	virtual void RectLPToRowRange(const CRect& rectLP,int& nFirstRow,int& nLastRow, BOOL bIncludePartiallyShownRows);
	virtual int LastViewableRow();

	// overridables
protected:
	virtual void GetRowWidthHeight(CDC* pDC,int& nRowWidth,int& nRowHeight,int& nCharWidth) = 0;
	virtual int GetActiveRow() = 0;
	virtual int GetRowCount() = 0;
	virtual void OnDrawRow(CDC* pDC, int nRow, int nY, BOOL bSelected) = 0;
	virtual void ChangeSelectionNextRow(BOOL bNext) = 0;
	virtual void ChangeSelectionToRow(int nRow) = 0;

// Implement 
protected:
	virtual void OnPrepareDC(CDC* pDC,CPrintInfo* pInfo = NULL);
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);

public:
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnSize(UINT nType, int cx, int cy);
};


